import {Injectable} from '@angular/core';

@Injectable()
export class TimerService {

  startTime = 0
  endTime = 0

  constructor() {
    console.log("TimerService对象被创建了")
  }

  start() {
    this.startTime = new Date().getTime()
  }

  end(actionName: string) {
    this.endTime = new Date().getTime()
    console.log(actionName + "操作耗时：", this.endTime - this.startTime)
  }
}
